package com.lagou.rpc.consumer.controller;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.config.RpcReference;
import com.lagou.rpc.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mcl
 * @date 2021/7/26 2:51 下午
 * @description
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @RpcReference
    private IUserService userService;

    @GetMapping("/get/{id}")
    public User getUserById(@PathVariable int id) {
        return userService.getById(id);
    }

    @GetMapping("/getUserByName/{name}")
    public User getUserByName(@PathVariable String name) {
        return userService.getByName(name);
    }
}
